package greedy.leetcode_252;

import java.util.Arrays;
import java.util.Comparator;

public class SortSolution {
    public boolean canAttendMeetings(int[][] intervals) {
        if (intervals.length == 0 || intervals[0].length == 0) {
            return true;
        }
        // 按照会议开始时间升序排列
        Arrays.sort(intervals, new Comparator<int[]>() {
            public int compare(int[] a, int[] b) {
                return a[0] - b[0];
            }
        });
        for (int i = 0; i < intervals.length; i++) {
            if (i + 1 < intervals.length && intervals[i][1] > intervals[i + 1][0]) {
                return false;
            }
        }
        return true;
    }
}
